package com.flurry.sdk;

import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import com.flurry.sdk.kb;
import java.lang.ref.WeakReference;

public class kc {
    private static kc a;
    /* access modifiers changed from: private */
    public static final String b = kc.class.getSimpleName();
    private Object c;

    public static synchronized kc a() {
        kc kcVar;
        synchronized (kc.class) {
            if (a == null) {
                a = new kc();
            }
            kcVar = a;
        }
        return kcVar;
    }

    private kc() {
        if (Build.VERSION.SDK_INT >= 14 && this.c == null) {
            Context context = jy.a().a;
            if (context instanceof Application) {
                this.c = new Application.ActivityLifecycleCallbacks() {
                    public final void onActivityCreated(Activity activity, Bundle bundle) {
                        km.a(3, kc.b, "onActivityCreated for activity:" + activity);
                        a(activity, kb.a.kCreated);
                    }

                    public final void onActivityStarted(Activity activity) {
                        km.a(3, kc.b, "onActivityStarted for activity:" + activity);
                        a(activity, kb.a.kStarted);
                    }

                    public final void onActivityResumed(Activity activity) {
                        km.a(3, kc.b, "onActivityResumed for activity:" + activity);
                        a(activity, kb.a.kResumed);
                    }

                    public final void onActivityPaused(Activity activity) {
                        km.a(3, kc.b, "onActivityPaused for activity:" + activity);
                        a(activity, kb.a.kPaused);
                    }

                    public final void onActivityStopped(Activity activity) {
                        km.a(3, kc.b, "onActivityStopped for activity:" + activity);
                        a(activity, kb.a.kStopped);
                    }

                    public final void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
                        km.a(3, kc.b, "onActivitySaveInstanceState for activity:" + activity);
                        a(activity, kb.a.kSaveState);
                    }

                    public final void onActivityDestroyed(Activity activity) {
                        km.a(3, kc.b, "onActivityDestroyed for activity:" + activity);
                        a(activity, kb.a.kDestroyed);
                    }

                    private static void a(Activity activity, kb.a aVar) {
                        kb kbVar = new kb();
                        kbVar.a = new WeakReference<>(activity);
                        kbVar.b = aVar;
                        kbVar.b();
                    }
                };
                ((Application) context).registerActivityLifecycleCallbacks((Application.ActivityLifecycleCallbacks) this.c);
            }
        }
    }

    public final boolean b() {
        return this.c != null;
    }
}
